public class Demo8 {
    public static void main(String[] args) {
        Object locker = new Object();

        Thread thread = new Thread(() -> {
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    System.out.println(Thread.currentThread().getName() + "结束运行");
                    break;
                }
            }
        });

        thread.start();
        thread.interrupt();
    }
}
